//Principal object of the application
var App = App || {};
//Initialize principal children
App.Router = App.Router || {};
App.Router.Default = Backbone.Router.extend({

    routes:{
    	"*actions":"defaultRoute"
    },
    
    initialize:function () {
    	$('.back').live('click', function(event) {
            window.history.back();            
            return false;
        });
    },    
    
    //Every page that not match the router will go to the homePage
    defaultRoute : function () {
    	var transition = $.mobile.defaultPageTransition;
        $.mobile.changePage("#home", {changeHash:false, transition: transition});
        App.Utils.displayApplicationMessages();
    }
});

//Entry Point of the Application
$(document).ready(function () {
	//Preloads every single HTML view, and then starts the application.
    App.Utils.loadViews([
							'invalid/view/reserveCreate',
							'invalid/view/reserveDetail',
							'invalid/view/reserveUpdate',
							'invalid/view/reserveList',
							'invalid/view/storeDetail',
							'invalid/view/storeList'
                        ],
        function () {
    		new App.Router.Default();
			new App.Reserves.Router.ReservesRouter();
            Backbone.history.start();
    });
});
